<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>test</title>
  </head>
  <body>
    <div id="app">
      <form class="" action="" method="">
        <div class="">
          用户名：
          <input type="text" v-on:keyup.delete="clear" v-model="uname">
        </div>
        <div class="">
          密码：
          <input type="text" name="" value="" v-on:keyup.enter="handleSubmit" v-model="pwd">
        </div>
        <div class="">
          <input type="button" v-on:click="handleSubmit" name="" value="提交">
        </div>
      </form>
    </div>
    <script type="text/javascript" src="js/vue.js"></script>
    <script type="text/javascript">
      var vm = new Vue({
        el: '#app',
        data: {
          uname: '',
          pwd: '',
        },
        methods: {
          handleSubmit: function(){
            console.log(this.uname, this.pwd);
          },
          clear: function(){
            this.uname='';
          },
        },
      });
    </script>
  </body>
</html>
